f = open("d:/test.txt","r",encoding="utf-8")
# print(f"读取10个字节：{f.read(100)}")
# print(f"读取全部内容：{f.read()}")
# print(f"读取全部内容：{f.readline()}")
# print(f"读取全部内容：{f.readlines()}")

# for line in f:
#     print(f"读取一行：{line}")
# f.close()

# with open("d:/test.txt","r",encoding="utf-8") as f:
#     for line in f:
#         print(f"读取一行：{line}")

# with open("d:/test.txt","r",encoding="utf-8") as f:print(f"2出现的次数：{f.read().count("2")}")

with open("d:/test.txt","w",encoding="utf-8") as f:
    f.write("12345\n1234\n123\n12\n1\n")
    f.flush()